package com.thermofisher.controller;

import com.thermofisher.beans.HomeData;
import com.thermofisher.beans.SearchProject;
import com.thermofisher.service.HomeService;
import com.thermofisher.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/home")
public class HomeController
{

    @Autowired
    private HomeService homeService;

    @PostMapping("/getHomeData")
    public Result getHomeData(@RequestBody SearchProject searchProject)
    {
        HomeData homeData = homeService.getHomeData(searchProject);
        Result result = new Result(String.valueOf(HttpStatus.OK.value()),
                                   HttpStatus.OK.getReasonPhrase(),
                                   homeData);
        return result;
    }

}

